#9_1_5 列表的循环遍历练习

list1 = [1,2,3,4,5,6,7,8,9,10]

def even_list_while(List):
    Tmp = []
    i = 0
    while i<len(List):
        if List[i]%2==0:
            Tmp.append(List[i])
        i+=1
    return Tmp

tmp1 = even_list_while(list1)
print(f"while循环取出列表偶数为:{tmp1}")

def even_list_for(List):
    Tmp = []
    for x in List:
        if x%2 == 0:
            Tmp.append(x)
    return Tmp
tmp2 = even_list_for(list1)
print(f"for循环取出列表偶数为:{tmp2}")




